//
//  ViewController.m
//  02_UIViewController
//
//  Created by dllo on 16/7/15.
//  Copyright © 2016年 yh. All rights reserved.
//

#import "ViewController.h"
#import "PresentViewController.h"
@interface ViewController ()
@property (nonatomic, strong) UIView *subView;

@end

@implementation ViewController
// 初始化方法
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // 不要再这个方法中加载视图
        // 在这个方法中去初始化一些数据相关的内容
    }
    return self;
}

// 加载ViewController中的view
// UINavagationController UITableViewController在loadView中给赋值的
- (void)loadView {
    [super loadView];
    NSLog(@"loadView");
}

// view已经加载
// 自定义视图创建
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    NSLog(@"viewDidLoad");
    self.view.backgroundColor = [UIColor cyanColor];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeSystem];
    
    // 模态
    
    
    
}

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
    PresentViewController *present = [[PresentViewController alloc] init];
    // 模态出一个视图控制器
    present.modalTransitionStyle = 1; // 翻页的效果
    [self presentViewController:present animated:YES completion:nil];
}


// 下列方法 会执行多次+
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
}

- (void)viewDidDisappear:(BOOL)animated {
    [super viewDidDisappear:animated];
}

// init loadView viewDidLoad 只执行一次
// 懒加载
- (UIView *)subView {
    if (_subView == nil) {
        _subView = [UIView new];
    }
    return _subView;
}

// 接收到内存警告时 实现的方法
- (void)didReceiveMemoryWarning {
    // 从父类继承的方法中有内存警告的打印
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
    // 释放部分内存资源
}

@end
